Option Strict On
Option Explicit On
'Copyright (c) 2007-2010, William Severance, Jr., WESNet Designs
'All rights reserved.

'Redistribution and use in source and binary forms, with or without modification, are permitted
'provided that the following conditions are met:

'Redistributions of source code must retain the above copyright notice, this list of conditions
'and the following disclaimer.

'Redistributions in binary form must reproduce the above copyright notice, this list of conditions
'and the following disclaimer in the documentation and/or other materials provided with the distribution.

'Neither the name of William Severance, Jr. or WESNet Designs may be used to endorse or promote
'products derived from this software without specific prior written permission.

'Disclaimer: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
'            OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
'            AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE
'            FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
'            LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
'            INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
'            OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
'            IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

'Although I will try to answer questions regarding the installation and use of this software when
'such questions are submitted via e-mail to the below address, no promise of further
'support or enhancement is made nor should be assumed.

'Developer Contact Information:
'     William Severance, Jr.
'     WESNet Designs
'     679 Upper Ridge Road
'     Bridgton, ME 04009
'     Phone: 207-647-9375
'     E-Mail: bill@wesnetdesigns.com
'     Website: www.wesnetdesigns.com

Namespace WESNet.DNN.Modules.EPrayer
    Public Class UserInfo
        Inherits DotNetNuke.Entities.Users.UserInfo

#Region "Private Members"
        Private _ModuleID As Integer = -1
        Private _Alias As String
        Private _Signature As String
        Private _IdentifyBy As Integer
        Private _PageSize As Integer
        Private _OrderBy As String
        Private _MailFormat As DotNetNuke.Services.Mail.MailFormat
        Private _IsTrusted As Boolean
        Private _IsModerator As Boolean
        Private _ViewableDistributions As Integer = -1
        Private _IsBanned As Boolean
        Private _BannedUntilDate As DateTime
        Private _Visits As Integer
        Private _Requests As Integer
        Private _Updates As Integer
        Private _LastPostID As Integer
        Private _LastVisitedDate As DateTime
        Private _LastPostedDate As DateTime
        Private _IsTrackingAllPosts As Boolean
        Private _TrackingStartedDate As DateTime
#End Region

#Region "Public Properties"

        Public Property ModuleID() As Integer
            Get
                Return _ModuleID
            End Get
            Set(ByVal value As Integer)
                _ModuleID = value
            End Set
        End Property

        Public Property [Alias]() As String
            Get
                Return _Alias
            End Get
            Set(ByVal value As String)
                _Alias = value
            End Set
        End Property

        Public Property Signature() As String
            Get
                Return _Signature
            End Get
            Set(ByVal value As String)
                _Signature = value
            End Set
        End Property

        Public Property IdentifyBy() As Integer
            Get
                Return _IdentifyBy
            End Get
            Set(ByVal value As Integer)
                _IdentifyBy = value
            End Set
        End Property

        Public Property PageSize() As Integer
            Get
                Return _PageSize
            End Get
            Set(ByVal value As Integer)
                _PageSize = value
            End Set
        End Property

        Public Property OrderBy() As String
            Get
                Return _OrderBy
            End Get
            Set(ByVal value As String)
                _OrderBy = value
            End Set
        End Property

        Public Property MailFormat() As DotNetNuke.Services.Mail.MailFormat
            Get
                Return _MailFormat
            End Get
            Set(ByVal value As DotNetNuke.Services.Mail.MailFormat)
                _MailFormat = value
            End Set
        End Property

        Public Property ViewableDistributions() As Integer
            Get
                Return _ViewableDistributions
            End Get
            Set(ByVal value As Integer)
                _ViewableDistributions = value
            End Set
        End Property

        Public Property IsTrusted() As Boolean
            Get
                Return _IsTrusted
            End Get
            Set(ByVal value As Boolean)
                _IsTrusted = value
            End Set
        End Property

        Public Property IsBanned() As Boolean
            Get
                Return _IsBanned
            End Get
            Set(ByVal value As Boolean)
                _IsBanned = value
            End Set
        End Property

        Public Property BannedUntilDate() As DateTime
            Get
                Return _BannedUntilDate
            End Get
            Set(ByVal value As DateTime)
                _BannedUntilDate = value
            End Set
        End Property

        Public Property IsTrackingAllPosts() As Boolean
            Get
                Return _IsTrackingAllPosts
            End Get
            Set(ByVal value As Boolean)
                _IsTrackingAllPosts = value
            End Set
        End Property

        Public Property TrackingStartedDate() As DateTime
            Get
                Return _TrackingStartedDate
            End Get
            Set(ByVal value As DateTime)
                _TrackingStartedDate = value
            End Set
        End Property

        Public Property Visits() As Integer
            Get
                Return _Visits
            End Get
            Set(ByVal value As Integer)
                _Visits = value
            End Set
        End Property

        Public Property Requests() As Integer
            Get
                Return _Requests
            End Get
            Set(ByVal value As Integer)
                _Requests = value
            End Set
        End Property

        Public Property Updates() As Integer
            Get
                Return _Updates
            End Get
            Set(ByVal value As Integer)
                _Updates = value
            End Set
        End Property

        Public Property LastPostID() As Integer
            Get
                Return _LastPostID
            End Get
            Set(ByVal value As Integer)
                _LastPostID = value
            End Set
        End Property

        Public Property LastVisitedDate() As DateTime
            Get
                Return _LastVisitedDate
            End Get
            Set(ByVal value As DateTime)
                _LastVisitedDate = value
            End Set
        End Property

        Public Property LastPostedDate() As DateTime
            Get
                Return _LastPostedDate
            End Get
            Set(ByVal value As DateTime)
                _LastPostedDate = value
            End Set
        End Property

        Public Property IsModerator() As Boolean
            Get
                Return _IsModerator
            End Get
            Set(ByVal value As Boolean)
                _IsModerator = value
            End Set
        End Property

        Public ReadOnly Property IsGlobalUser() As Boolean
            Get
                Return _ModuleID = -1 And UserID <> -1
            End Get
        End Property

        Public ReadOnly Property IsAnonymous() As Boolean
            Get
                Return UserID = -1
            End Get
        End Property

#End Region

#Region "Constructors"

        Public Sub New()
            MyBase.New()
            _Alias = "Anonymous"
            _PageSize = -1
            _OrderBy = "Order_Date_DESC"
            _Signature = String.Empty
        End Sub

        Public Sub New(ByVal ModuleID As Integer)
            MyBase.New()
            _ModuleID = ModuleID
            _Alias = "Anonymous"
            _PageSize = -1
            _OrderBy = "Order_Date_DESC"
            _Signature = String.Empty
        End Sub

        Public Sub New(ByVal ModuleID As Integer, ByVal [Alias] As String, ByVal Signature As String, ByVal ViewableDistributions As Integer, ByVal IsTrusted As Boolean)
            MyBase.New()
            _ModuleID = ModuleID
            _Alias = [Alias]
            _Signature = Signature
            _PageSize = -1
            _OrderBy = "Order_Date_DESC"
            _ViewableDistributions = ViewableDistributions
            _IsTrusted = IsTrusted
            UserID = UserID
        End Sub

#End Region

#Region "Public Shared Methods"

        Public Shared Function AliasIsValid(ByVal ModuleId As Integer, ByVal [Alias] As String) As Boolean
            Dim PortalId As Integer = PortalController.GetCurrentPortalSettings.PortalId
            Dim epc As New EPrayerController

            'Return True if Alias is not a DNN Username and is not already in EPrayer Users table
            Return DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, [Alias]) Is Nothing _
                     AndAlso epc.GetUser(ModuleId, [Alias]) Is Nothing
        End Function
#End Region

    End Class
End Namespace
